#ifndef _COMM_MEM_ALLOC_H_
#define _COMM_MEM_ALLOC_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdlib.h>

void * get_mem(size_t n);
void release_mem(void * p, size_t n);

void mem_save_exit();

#define GET_OBJECT(Type) ((Type*)get_mem(sizeof(Type)))
#define GET_OBJECT_N(Type, cnt) ((Type*)get_mem(sizeof(Type)*cnt))

#define RELEASE_OBJECT(Type, p) release_mem(p, sizeof(Type))
#define RELEASE_OBJECT_N(Type, p, cnt) release_mem(p, sizeof(Type) * cnt)

#ifdef __cplusplus
}
#endif

#endif  // _COMM_MEM_ALLOC_H_

